﻿
//Author: 张亚涛
//createtime:2015-12-23 22:46:51
//Description: 

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NS.BLL.Systems;
using Model;
using DAL;

namespace BLL
{

    /// <summary>
    /// 该类提供了一系列操作 "Park" 表的方法;
    /// </summary>
    public class ParkService
    {
        #region .对本表的维护.
        #region select data
        /// <summary>
        /// 返回Park表的所有数据  
        /// </summary>
        /// <param name="CommuntyID">小区ID</param>
        /// <param name="ParentID">父ID</param>
        /// <returns></returns>        
        public static List<Park> GetAllPark(string CommuntyID, string ParentID)
        {
            return ParkBase.GetAllPark(CommuntyID, ParentID);
        }
        /// <summary>
        /// 根据Park表的ParkID字段返回数据  
        /// </summary>
        /// <param name="parkID">ParkID</param>
        /// <returns></returns>        
        public static Park GetParkByParkID(long parkID)
        {
            return ParkBase.GetParkByParkID(parkID);
        }
        /// <summary>
        /// 根据车位ID返回停车场全称
        /// </summary>
        /// <param name="typeID">车位ID</param>
        /// <returns></returns>       
        public static string GetFullNameByParkID(long parkID)
        {
            StringBuilder sbPath = new StringBuilder();
            Park Model = ParkService.GetParkByParkID(parkID);
            if (Model != null)
            {
                string[] MyArray = (Model.ParentPath + "," + parkID.ToString()).Split(',');
                foreach (string TypeID in MyArray)
                {
                    if (TypeID != "0")
                    {
                        string strName = UtilityService.GetFieldValueByPK("Park", "ParkName", "ParkID", TypeID)[0].ToString();
                        sbPath.Append(strName + " - ");
                    }
                }
            }
            string fullName = sbPath.ToString(); ;
            if (fullName.Length > 1)
            {
                fullName = fullName.Substring(0, fullName.Length - 3);
            }
            return fullName;
        }
        #endregion
        #region delete data
        /// <summary>
        /// 根据Park表的ParkID字段删除数据 
        /// </summary>
        /// <param name="parkID">parkID</param>
        /// <returns>返回受影响的行数</returns>
        public static int DeleteParkByParkID(long parkID)
        {
            return ParkBase.DeleteParkByParkID(parkID);
        }
        #endregion
        #region update data
        /// <summary>
        /// 根据Park表的ParkID字段更新数据 
        /// </summary>
        /// <param name="parkID">ParkID</param>
        /// <param name="Park">park</param>
        /// <returns>返回受影响的行数</returns>
        public static int UpdateParkByParkID(Park park)
        {
            return ParkBase.UpdateParkByParkID(park);
        }
        #endregion
        #region insert data
        /// <summary>
        /// 向Park表插入一条数据，插入成功则返回自增列数值，插入不成功则返回-1 
        /// </summary>
        /// <param name="park">Park</param>        
        /// <returns></returns>
        public static int AddPark(Park park)
        {
            return ParkBase.AddPark(park);
        }
        #endregion
        #endregion

        #region .SQL语句汇总.
        /// <summary>
        /// 返回Park表的所有数据（SQL语句） 
        /// </summary>
        /// <returns></returns>        
        public static string GetAllPark_SQL(string CommuntyID, string ParentID)
        {
            return ParkBase.GetAllPark_SQL(CommuntyID, ParentID);
        }
        #endregion
    }
}